package com.crb.smartcard.utils;

public class ReverseUtil {

    public static String reverse(String str) {
        if (isEmpty(str)) {
            return null;
        }
        //String str="10203040506";
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if ((i + 1) % 2 == 0) {
                //获取上一个
                char pre = str.charAt(i - 1);
                //当前的
                char current = str.charAt(i);
                sb.append(current).append(pre);
            }
        }
        //如果是奇数则再加上最后一位
        if (str.length() % 2 != 0) {
            sb.append(str.charAt(str.length() - 1));
        }
        return sb.toString();
    }


    public static boolean isEmpty(String... ss) {
        if (ss == null) {
            return true;
        }
        for (String s : ss) {
            if (s == null || s.length() < 1 || "null".equals(s)) {
                return true;
            }
        }
        return false;
    }
}
